package com.employee.controller;

import com.employee.pojo.dto.*;
import com.employee.pojo.entry.Position;
import com.employee.pojo.entry.User;
import com.employee.pojo.result.Result;
import com.employee.pojo.vo.StaffVo;
import com.employee.service.StaffService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.text.ParseException;
import java.util.List;

/**
 * @AUTHOR 尹书岿
 * @DATE 2025/1/9 18:47
 * @DESCRIBE
 */
@RestController
public class StaffController {
    @Autowired
    private StaffService staffService;

    @GetMapping("/getStaffList")
    public Result<List<StaffVo>> getStaffList() {
        return Result.success(staffService.getStaffList());
    }

    @PostMapping("/addStaff")
    public Result addStaff(@RequestBody StaffDTO data) {
        System.out.println(data);
        staffService.addStaff(data);
        return Result.success();
    }
    @PostMapping("/updateStaff")
    public Result updateStaff(@RequestBody UpdateStaffDTO data) {
        System.out.println(data);
        staffService.updateStaff(data);
        return Result.success();
    }

    @PostMapping("/selectStaff")
    public Result<List<StaffVo>> selectStaff(@RequestBody SelectStaffDTO data) throws ParseException {
        List<StaffVo> staffListByQuery = staffService.getStaffListByQuery(data);
        System.out.println("-----------------"+data.getStatus());
        return Result.success(staffListByQuery);
    }
    @GetMapping("/updateEmpStatus/{empId}/{empStatus}")
    public Result updateEmpStatus(@PathVariable("empId") Integer empId, @PathVariable("empStatus") String empStatus) {
        staffService.updateEmpStatus(empId, empStatus);
        return Result.success();
    }
    @PostMapping("/updateEmpDeptId")
    public Result updateEmpDeptId(@RequestBody UpdateEmpDeptDto updateEmpDeptDto) {
        staffService.updateEmpDeptId(updateEmpDeptDto);
        return Result.success();
    }
    @PostMapping("//updateEmpPosId")
    public Result updateEmpPosId(@RequestBody UpdateEmpPosDto updateEmpPosDto) {
        staffService.updateEmpPosId(updateEmpPosDto);
        return Result.success();
    }

}
